import numpy
from getFunction import getInversionCount
from listnode import ListNode
from typing import Optional,Tuple,List

def IsWall(node: numpy.array, dirt:int, row: int, col:int) -> bool:
    ans = True
    if dirt == 0:
        ans = (row - 1 < 0)
    elif dirt == 1:
        ans = (row + 1) >= node.shape[0]
    elif dirt == 2:
        ans = (col - 1 < 0)
    elif dirt == 3:
        ans = (col + 1 >= node.shape[1])
    return ans

def IsSolvable(start: numpy.array, end: numpy.array) -> bool:
    Ns = getInversionCount(start)
    Ne = getInversionCount(end)
    extra = 0 if start.shape[1] % 2 != 0 else abs(find_elem(start, 0)[1] - find_elem(end, 0)[1])
    if (Ns + extra) % 2 == Ne % 2:
        return True
    else:
        return False
